<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>PUT请求</title>
	</head>
	<body>
		<h1>前后端调用-PUT请求测试</h1>
		<script src="../js/axios.js"></script>
		<script>
			/*
				需求：要求将id="323"
					改为name="小鬼当家"，age=4,sex="男"
			*/
		   let user = {
			   id: 323,
			   name: '小鬼当家',
			   age: 4,
			   sex: '男'
		   }
		   let url = "http://localhost:8080/axios/updateUser"
		   axios.put(url,user)
				.then(abc=>{
					console.log(abc.data)
				})
			
			/*
			需求2：要求将name="小燕子"
			改为name="小鬼当家",age=18,sex=男
			难点：如果有多个参数，并且重复时，如何封装？
			解决方案： restful + 对象
			*/
		   let name = "小燕子"
		   let user2 = {
			   name: "小鬼当家",
			   age: 18,
			   sex: "男"
		   }
		   let url2 = `http://localhost:8080/axios/updateUserByName/${name}`
		   axios.put(url2,user2)
				.then(promise => {
					console.log(promise.data)
				})
			
		</script>
	</body>
</html>